package com.smz.controller;

import com.smz.entity.TDepartment;
import com.smz.entity.TPost;
import com.smz.service.TDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api
@RestController
public class TDepartmentController {
    @Autowired
    private TDepartmentService tDepartmentService;



    @ApiOperation("查找全部部门")
    @GetMapping("/tDepartments")
    public ResponseEntity<List<TDepartment>> findAllTDepartments(){
        List<TDepartment> tDepartments=tDepartmentService.findAllTDepartment();
        return ResponseEntity.ok(tDepartments);
    }

    @ApiOperation("增加部门")
    @PostMapping("/tDepartment")
    public ResponseEntity<String>addTDepartment(@RequestBody TDepartment tDepartment){
        tDepartmentService.addTDepartment(tDepartment);
        return  ResponseEntity.ok("ok");
    }

    @ApiOperation("删除部门")
    @DeleteMapping("/tDepartment")
    public  ResponseEntity<String>deleteTDepartment(@PathVariable("id")Integer id){
        tDepartmentService.removeTDepartmentById(id);
        return ResponseEntity.ok("ok");
    }

    @ApiOperation("更新部门")
    @PutMapping("/tDepartment")
    public ResponseEntity<String>updateTDepartment(@RequestBody TDepartment tDepartment){
        tDepartmentService.modifyTDepartment(tDepartment);
        return  ResponseEntity.ok("ok");
    }

}
